<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>${title}</title>
<link rel="stylesheet"
	href="${basePath}/static/bootstrap/css/bootstrap.css" />
<link href="${basePath}/static/css/basic.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css/login.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css/list.css" rel="stylesheet"
	type="text/css">
<script type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript"
	src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_style.css" rel="stylesheet"
	type="text/css">
</head>
<body>
	<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

	<!--内容部分-->
	<div class="list_main lay_out" class="clearfix">
		<div class="list_DH">
			<%@include file="/WEB-INF/templates/common/qualityNav.jsp"%>
		</div>
		<div class="list_NR">
			<div class="loc">
				<h3 style="margin: 0">查看病案已质控信息</h3>
			</div>
			<div class="list_con_table">
				<div class="search_table">
					<ul class="clearfix" style="margin-bottom: 0;">
						<input type="hidden" id="medLevel" value="${ medicalRecordVo.medLevel}">
						<input type="hidden" id="maxPoints" value="${ medicalRecordVo.maxPoints}">
						<input type="hidden" id="minPoints" value="${ medicalRecordVo.minPoints}">
						<input type="hidden" id="qualityType" value="${medicalRecordVo.type}">
						<li class="Label_1" style="width:12%">ID号：&nbsp;</li>
						<li class="Label_2"><input class="input_box" type="text"
							name='mrId' id='mrId' value='' /></li>
						<li class="Label_1" style="width:12%">住院次数：&nbsp;</li>
						<li class="Label_2"><input class="input_box" type="text"
							id='visitNumber' value='' /></li>
						<li class="Label_1" style="width:12%">身份证：&nbsp;</li>
						<li class="Label_2" style="width:24%"><input class="input_box" type="text" 
							name='idCard' id='idCard' value='' /></li>
						<li class="Label_1" style="width:12%">姓名：&nbsp;</li>
						<li class="Label_2"><input class="input_box" type="text" value='' id="name">
					    <li class="Label_1" style="width: 12%">出院科室：&nbsp;</li>
						<li class="Label_2" >
							<select class="input_box" id="outHospitalOfficeId">
								<option value="">请选择</option>
								<c:forEach var="office" items="${officeList }">
									
									<c:choose>
									<c:when test="${medicalRecordVo.officeId == office.code }">
										<option selected="selected" value="${office.code }">${office.name}</option>
									</c:when>
									<c:otherwise>
										<option value="${office.code }">${office.name}</option>
									</c:otherwise>
								</c:choose>
								</c:forEach>

						</select>
						</li>
						<li class="Label_1" style="width:12%">出院日期：&nbsp;</li>
						<li class="Label_4" style="width:24%;text-align:center;"><input
							class="input_box" type="text" style="width:42%"
							name='startTime' id='startTime'  value="${startTime}" 
							onFocus="WdatePicker()" /><span>&nbsp;-&nbsp;</span><input
							class="input_box" type="text" style="width:42%"
							name='endTime' id='endTime'  value="${endTime}" 
							onFocus="WdatePicker()" /></li>					
						
						<li class="Label_5">
							<div class="right" style="text-align: right">
								<a onclick="searchQua()">查询</a> <!-- <a onclick="exportExecl()">导出</a> -->
							</div>
						</li>

					</ul>
				</div>
				<table class="Search_tableList" cellpadding="0" cellspacing="0">
					<tr>
						<td class="tdLabel_4">姓名</td>
						<td class="tdLabel_4">证件号码</td>
						<td class="tdLabel_4">ID号</td>
						<td class="tdLabel_4">住院次数</td>
						<td class="tdLabel_4">出院科室</td>
						<td class="tdLabel_4">病案等级</td>
						<td class="tdLabel_4">质控分数</td>
						<td class="tdLabel_4">操作</td>
					</tr>
                    <tr id="loading" style="height:50px;display:none">
	                 <td colspan="7" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
	                </tr>
					<tbody id="tbody">
						<c:forEach items="${qualityList}" var="quality">
							<tr>
								<td class="tdLabel_5">${quality.name}</td>
								<td class="tdLabel_5">${ quality.idCard}</td>
								<td class="tdLabel_5">${quality.mrId}</td>
								<td class="tdLabel_5">${quality.visitNumber}</td>
								<td class="tdLabel_5">${ quality.outOfficeName}</td>
								<td class="tdLabel_5">${ quality.level}</td>
								<td class="tdLabel_5">${quality.qcPoints}</td>
								<td class="tdLabel_5"><a class="int" firstGuid="${quality.firstGuid}" onclick="updateMedQua(this)">查看</a></td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<div class="pageList">
				<ul class="pagination clearfix" id="page_plus"></ul>
				<div class="pagination">
					<div>
						总共：<b id="totalPage">0</b> 条信息 当前页是第 <b id="currentPage">0/0</b> 页
					</div>
				</div>
			</div>
		</div>
	</div>
	<!------页脚部分--------->
	<%@include file="/WEB-INF/templates/common/footer.jsp"%>

	<!--JS部分-->
	<script type="text/javascript">
	

	$("#mrId").change(function(){
		var $this=$(this);
		var inentity=$this.val();
		if(inentity!=null && inentity!='' && inentity!=undefined){
			if(isContainMark(inentity)){
				var mrId=inentity.split("-")[0];
				var visitNumber=inentity.split("-")[1];
				//alert(mrId+"--"+visitNumber);
				$("#mrId").val("").val(mrId);
				$("#visitNumber").val("").val(visitNumber);
				queryQua(1,10);
			}
		}
	});

	function isContainMark(inentity){
		var reg = RegExp(/-/);
		return reg.test(inentity);
	}
	
	
		$(function(){
			$("#mrId").focus();
			var quality= $("#qualityType").val();
			if(quality){
				queryQua(1, 10);
			}
			
			
			
		});

		function searchQua() {
			queryQua(1, 10);
		}

		function queryQua(pageNo, pageSize) {
			var startTime = $("#startTime").val();
			var endTime = $("#endTime").val();
			var name = $("#name").val();
			var mrId = $("#mrId").val();
			var idCard = $("#idCard").val();
			var outHospitalOfficeId=$("#outHospitalOfficeId").val();
			var visitNumber=$("#visitNumber").val();
			var medLevel=$("#medLevel").val();
			var maxPoints=$("#maxPoints").val(); 
			var minPoints=$("#minPoints").val();
			

			if ((startTime == null || startTime == "")
					&& (endTime == null || endTime == '')
					&& (name == null || name == '')
					&& (mrId == null || mrId == '')
					&& (visitNumber == null || visitNumber == '')
					&& (outHospitalOfficeId == null || outHospitalOfficeId == '')
					&& (idCard == null || idCard == '')) {
				layer.alert("请输入查询条件!", {
					icon : 0
				});

				return;
			}

			$.ajax({
						type : "post",
						url : "${basePath}/quality/selectQualityListByKeywords",
						data : {
							startTime : startTime,
							endTime : endTime,
							name : name,
							mrId : mrId,
							idCard : idCard,
							visitNumber : visitNumber,
							officeId : outHospitalOfficeId,
							medLevel:medLevel,
							maxPoints:maxPoints,
							minPoints:minPoints,
							pageNo : pageNo,
							pageSize : pageSize
						},
                        beforeSend:function(){
			    	 		$("#tbody").html("");
			    	 		$("#loading").show();
			    	 	},
						success : function(data) {
							//console.log(data);
							$("#loading").hide();
							if (data.success) {
								var count = data.data.totalCount;
								var qualityList = data.data.qualityList;
								var len = qualityList.length;
								if (len > 0) {

									var html = "";
									for (var i = 0; i < len; i++) {
										var obj = qualityList[i];
										
										var points=obj.points==undefined?0:obj.points;
										var point = 100-parseFloat(points);
										html += "<tr>"
												+ "  <td class='tdLabel_5'>"
												+ (obj.name==undefined?'':obj.name)
												
												+ "</td>"
												+ "  <td class='tdLabel_5'>"
												+(obj.idCard==undefined?'':obj.idCard)
												+ "</td>"
												+ "  <td class='tdLabel_5'>"
												+ (obj.mrId==undefined?'':obj.mrId)
											
												+ "</td>"
												+ "  <td class='tdLabel_5'>"
												+ (obj.visitNumber==undefined?'':obj.visitNumber)
											
												+ "</td>"
												+ "  <td class='tdLabel_5'>"
												+ (obj.outOfficeName==undefined?'':obj.outOfficeName)
												+ "</td>"
												+ "  <td class='tdLabel_5'>"
												+ (obj.level==undefined?'':obj.level)
												+ "</td>"
												+ "  <td class='tdLabel_5'>"
												+ point
												+ "</td>"
												+ "  <td class='tdLabel_5'><a class='int' firstGuid='"
												+ obj.firstGuid
												+ "'  onclick='updateMedQua(this)'>查看</a></td>"
												+ "</tr>";
									}
									$("#tbody").html("").html(html);
									page(pageNo, count);
								} else {
									$("#tbody").html("");
									$("#currentPage").html("0/0");
									$("#totalPage").html("0");
									$("#page_plus").html("");
									layer.alert('查询数据为空!', {
										icon : 5
									});
								}

							} else {
								$("#tbody").html("");

								$("#currentPage").html("0/0");
								$("#totalPage").html("0");
								$("#page_plus").html("");
								layer.alert(data.msg, {
									icon : 5
								});

							}

						}

					})

		}

		function page(currentPage, totalCounts) {
			var pageSize = 10;
			var visiblePages = 10;
			var totalPages = Math.ceil(totalCounts / pageSize);
			$('#page_plus').jqPaginator({
				totalCounts : totalCounts,
				pageSize : pageSize,
				visiblePages : visiblePages,
				currentPage : currentPage,
				first : '<li class="first"><a href="javascript:void(0);">首页</a></li>',
				prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
				next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
				last : '<li class="last"><a href="javascript:void(0);">末页</a></li>',
				page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
				onPageChange : function(num, type) {
					if (type != 'init') {
						queryQua(num, pageSize);
					}
					$("#totalPage").html(totalCounts);
					$("#currentPage").html(num + "/" + totalPages);
				}
			});
		}

		function updateMedQua(obj) {
			var $this = $(obj);
			var firstGuid = $this.attr("firstGuid");
			window.location.href = "${basePath}/quality/updateMedQua?firstGuid="
					+ firstGuid;
		}
	</script>

</body>
</html>